package com.cx.base.day19_thread;

/**
 * @Author: robert.song
 * @Date: Created in 2021/7/29
 */

public class Thread_1_Method_Join {
    public static void main(String[] args) {
        Thread thread = new Thread(new Runnable() {
            public void run() {
                for (int i = 0; i < 60; i++) {
                    System.out.println("子线程,i" + i);
                }
            }
        }, "t1");
        thread.start();
        try {
            // 其他线程变为等待状态,等thread线程执行完成后才能执行join方法
            thread.join();
            System.out.println(thread.getId() + "," + thread.getName() + "," + thread.getPriority() + "," + thread.getState());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        for (int i = 0; i < 30; i++) {
            System.out.println("主线程,i" + i);
        }
    }

}
